package h.c.z.designPattern.C01_FactoryPattern.AbstractFactory;


/**
 * [客户端]屌丝升级 有媳妇了-->有钱了，请厨师了 --> 升级土豪 请各系厨师
 * @author jinsicao
 *
 */
public class EatWithAbstractFactory01 {

	public static void main(String[] args) {

//		AbstractFactory af = new GuangzhouFactory();
		AbstractFactory af = new ShandongFactory();
		AbstractRedMeatProduct meatProduct = af.createRedMeat();
		meatProduct.createProduct();
		AbstractSteamedFishProduct fishProduct = af.createSteamedFish();
		fishProduct.createProduct();
	}

}


/**
 * 可扩展的抽象工厂接口
 * @author jinsicao
 */
interface AbstractFactory {
	
	/**
	 * 创建抽象红烧肉的对象
	 * @return
	 */
	public AbstractRedMeatProduct createRedMeat();
	
	/**
	 * 创建抽象清蒸鱼的对象
	 * @return
	 */
	public AbstractSteamedFishProduct createSteamedFish();
}

/**
 * 鲁菜厨师工厂
 * @author jinsicao
 *
 */
class ShandongFactory implements AbstractFactory {

	@Override
	public AbstractRedMeatProduct createRedMeat() {
		return new ShandongCuisineRedMeatProduct();
	}

	@Override
	public AbstractSteamedFishProduct createSteamedFish() {
		return new ShandongCuisineSteamedFishProduct();
	}
	
}


/**
 * 粤菜厨师工厂
 * @author jinsicao
 *
 */
class GuangzhouFactory implements AbstractFactory {

	@Override
	public AbstractRedMeatProduct createRedMeat() {
		return new GuangzhouCuisineRedMeatProduct();
	}

	@Override
	public AbstractSteamedFishProduct createSteamedFish() {
		return new GuangzhouCuisineSteamedFishProduct();
	}
	
}


/**
 * 获取食物接口
 * @author jinsicao
 */
interface Product {
	
	/**
	 * 加工食物
	 * @return
	 */
	public void createProduct();
}

/**
 * 红烧肉
 * @author jinsicao
 *
 */
interface AbstractRedMeatProduct extends Product {

}

/**
 * 鲁菜红烧肉
 * @author jinsicao
 */
class ShandongCuisineRedMeatProduct implements AbstractRedMeatProduct {

	@Override
	public void createProduct() {
		System.out.println("鲁菜红烧肉");
	}
	
}

/**
 * 粤菜红烧肉
 * @author jinsicao
 */
class GuangzhouCuisineRedMeatProduct implements AbstractRedMeatProduct {
	
	@Override
	public void createProduct() {
		System.out.println("粤菜红烧肉");
	}
	
}


/**
 * 清蒸鱼
 * @author jinsicao
 *
 */
interface AbstractSteamedFishProduct extends Product {
	
}


/**
 * 鲁菜清蒸鱼
 * @author jinsicao
 */
class ShandongCuisineSteamedFishProduct implements AbstractSteamedFishProduct {

	@Override
	public void createProduct() {
		System.out.println("鲁菜清蒸鱼");
	}
	
}


/**
 * 粤菜红烧肉
 * @author jinsicao
 */
class GuangzhouCuisineSteamedFishProduct implements AbstractSteamedFishProduct {
	
	@Override
	public void createProduct() {
		System.out.println("粤菜清蒸鱼");
	}
	
}
